package org.jiuling.netty.config;

import java.util.concurrent.TimeUnit;

/**
 * 空间状态配置
 * @author 紫灵
 * @date 2025年07月07日 22时51分29秒
 */
public class IdleStateConfig {

    /** 读控弦市场 */
    private long readerIdleTime = 60;
    /** 写空闲时长 */
    private long writerIdleTime = 30;
    /** 读写空闲时长 */
    private long allIdleTime = 90;
    /** */
    private TimeUnit unit = TimeUnit.SECONDS;

    public long getReaderIdleTime() {
        return readerIdleTime;
    }

    public long getWriterIdleTime() {
        return writerIdleTime;
    }

    public long getAllIdleTime() {
        return allIdleTime;
    }

    public TimeUnit getUnit() {
        return unit;
    }

    public static Builder builder() {
        return new Builder();
    }

    public static class Builder {

        /** 空间状态配置 */
        private final IdleStateConfig idleStateConfig;

        public Builder() {
            this.idleStateConfig = new IdleStateConfig();
        }

        /**
         * 读空闲时长
         * @param readerIdleTime 读空闲时长
         * @return 当前对象
         */
        public Builder addReaderIdleTime(long readerIdleTime) {
            idleStateConfig.readerIdleTime = readerIdleTime;
            return this;
        }

        /**
         * 写空闲时长
         * @param writerIdleTime 写空闲时长
         * @return 当前对象
         */
        public Builder addWriterIdleTime(long writerIdleTime) {
            idleStateConfig.writerIdleTime = writerIdleTime;
            return this;
        }

        /**
         * 读写空闲时长
         * @param allIdleTime 读写空闲时长
         * @return 当前对象
         */
        public Builder addAllIdleTime(long allIdleTime) {
            idleStateConfig.allIdleTime = allIdleTime;
            return this;
        }

        /**
         * 时间单位
         * @param unit 时间单位
         * @return 当前对象
         */
        public Builder addUnit(TimeUnit unit) {
            idleStateConfig.unit = unit;
            return this;
        }

        /**
         * 构建空间状态配置
         * @return 空间状态配置
         */
        public IdleStateConfig build() {
            return idleStateConfig;
        }

    }

}
